//
//  BigIntellgientCell.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/7/27.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "BigIntellgientCell.h"
#import "OpusListModel.h"
@implementation BigIntellgientCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setModel:(OpusListModel *)model{
    _model = model;
    UILabel *firstlabel = [[UILabel alloc] init];
    firstlabel.text = _model.authorName;
    [self addSubview:firstlabel];
    [firstlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(cellScaleLeftAndRight(10));
        make.top.equalTo(self.mas_top);
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
        make.width.mas_equalTo(self.frame.size.width * 0.7);
    }];
    UILabel *secondlabel = [[UILabel alloc] init];
    secondlabel.text = _model.authorTitle;
    [self addSubview:secondlabel];
    [secondlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(cellScaleLeftAndRight(10));
        make.top.equalTo(firstlabel.mas_bottom);
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
        make.width.mas_equalTo(self.frame.size.width * 0.7);
    }];
    UIButton *collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:collectBtn];
    [collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(cellScaleTopAndBottom(15));
        make.right.equalTo(self.mas_right).offset(cellScaleLeftAndRight(-15));
        make.width.mas_equalTo(cellScaleLeftAndRight(20));
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
    UIImageView *bgImageView = [[UIImageView alloc] init];
    [bgImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",PictureIp,_model.imagepath] ] placeholderImage:[UIImage imageNamed:@""]];
    [self addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right);
        make.left.equalTo(self.mas_left).offset(cellScaleLeftAndRight(10));
        make.top.equalTo(secondlabel.mas_bottom);
        make.height.mas_equalTo(cellScaleTopAndBottom(185));
    }];
    UILabel *videotitleLabel = [[UILabel alloc] init];
    videotitleLabel.text = _model.title;
    [self addSubview:videotitleLabel];
    [videotitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right);
        make.left.equalTo(self.mas_left).offset(cellScaleLeftAndRight(10));
        make.top.equalTo(bgImageView.mas_bottom);
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
    UIImageView *watchImageView = [[UIImageView alloc] init];
    [self addSubview:watchImageView];
    [watchImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(cellScaleLeftAndRight(10));
        make.width.mas_equalTo(cellScaleLeftAndRight(30));
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
    UILabel *videowatchLabel = [[UILabel alloc] init];
    videowatchLabel.text = _model.count;
    [self addSubview:videowatchLabel];
    [videowatchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(watchImageView.mas_right).offset(cellScaleLeftAndRight(5));
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
        make.width.mas_equalTo(cellScaleLeftAndRight(120));
    }];
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:shareBtn];
    [shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(videotitleLabel.mas_bottom).offset(cellScaleTopAndBottom(10));
        make.right.equalTo(self.mas_right).offset(cellScaleLeftAndRight(-15));
        make.width.mas_equalTo(cellScaleLeftAndRight(20));
        make.height.mas_equalTo(cellScaleTopAndBottom(20));
    }];
//    firstlabel.backgroundColor = [UIColor redColor];
//    secondlabel.backgroundColor = [UIColor greenColor];
//    videowatchLabel.backgroundColor = [UIColor yellowColor];
//    videotitleLabel.backgroundColor = [UIColor blackColor];
//    watchImageView.backgroundColor = [UIColor cyanColor];
    bgImageView.backgroundColor = [UIColor lightGrayColor];
    shareBtn.backgroundColor = [UIColor lightGrayColor];
    collectBtn.backgroundColor = [UIColor lightGrayColor];

}
@end
